package com.gljx.web.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.activiti.engine.impl.util.CollectionUtil;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gljx.web.Entity.JournalEntry.BigCarJournal;
import com.gljx.web.dao.BigCarJournalMapper;
import com.gljx.web.dao.CommonDao;
import com.gljx.web.service.BigCarJournalService;


@Service
@Transactional
public class BigCarJournalServiceImpl extends CommonDao implements BigCarJournalService{

	@Autowired
	private BigCarJournalMapper bigCarJournalMapper;
	
	@Override
	public BigCarJournal queryBigCarByTime(String ksrq) {
		// TODO Auto-generated method stub
		return bigCarJournalMapper.selectBigCarByTime(ksrq);
	}

	@Override
	public List<BigCarJournal> queryBigCarByOneMonth(String startTime,String endTime) {
		// TODO Auto-generated method stub
		Map<String, String> map = new HashMap<>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		return bigCarJournalMapper.selectBigCarByOneMonth(map);
	}

	@Override
	public int addBigCarJournal(List<BigCarJournal> bigCarJournals, String startTime, String endTime) {
		// TODO Auto-generated method stub
		Map<String, String> map = new HashMap<>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		bigCarJournalMapper.deleteByTime(map);
		if (CollectionUtils.isEmpty(bigCarJournals)) {
			return 0;
		}
		return bigCarJournalMapper.insertBigCarJournal(bigCarJournals);
	}

}
